/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gtree;

import no.geosoft.cc.geometry.Geometry;
import no.geosoft.cc.graphics.*;

/**
 *
 * @author Gustavo
 */
public class gNode extends GObject {

    private gNode parent_;
    private double x_, y_;
    private GSegment circle_;
    private GSegment line_;
    private double SIZE = 30;

    gNode(GObject parent, String name, double x, double y) {
        parent_ = parent instanceof gNode ? (gNode) parent : null;

        x_ = x;
        y_ = y;

        line_ = new GSegment();
        addSegment(line_);

        circle_ = new GSegment();
        addSegment(circle_);

        circle_.setText(new GText(name, GPosition.MIDDLE));

        setStyle(new GStyle());

        parent.add(this);
    }

    double getX() {
        return x_;
    }

    double getY() {
        return y_;
    }

    public void draw() {
        if (parent_ != null) {
            line_.setGeometry(parent_.getX(), parent_.getY()+(SIZE/2), x_, y_+(SIZE/2));
            //line_.setGeometry(Geometry.createArrow((int) parent_.getX(), (int) parent_.getY(), (int) x_, (int) y_, 10, 10, 10));
        }

        //circle_.setGeometryXy(Geometry.createCircle(x_, y_, SIZE));
        circle_.setGeometryXy(Geometry.createRectangle(x_, y_, SIZE, SIZE));
    }
}
